Fix dtype mismatch in NemotronH/Zamba2 Mamba2 CUDA-kernel path (out_proj)#46487
Merged
Conversation
Signed-off-by: Yuekai Zhang <zhangyuekai@foxmail.com>
Contributor
|
[For maintainers] Suggested jobs to run (before merge) run-slow: nemotron_h, zamba2 |
Rocketknight1
approved these changes
Jun 8, 2026
Rocketknight1
left a comment
Member
There was a problem hiding this comment.
Yes, LGTM! Seems like a clean fix, and should be low risk because it's at worst a no-op.
Contributor
|
CI Dashboard: View test results in Grafana |
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
khushali9
pushed a commit
to khushali9/transformers
that referenced
this pull request
Jun 8, 2026
…proj`) (huggingface#46487) fix dtype mismatch Signed-off-by: Yuekai Zhang <zhangyuekai@foxmail.com>
louzongzhi
pushed a commit
to louzongzhi/transformers
that referenced
this pull request
Jun 10, 2026
…proj`) (huggingface#46487) fix dtype mismatch Signed-off-by: Yuekai Zhang <zhangyuekai@foxmail.com>
louzongzhi
pushed a commit
to louzongzhi/transformers
that referenced
this pull request
Jun 10, 2026
…proj`) (huggingface#46487) fix dtype mismatch Signed-off-by: Yuekai Zhang <zhangyuekai@foxmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The Mamba2 SSM CUDA-kernel forward path (
cuda_kernels_forward) projects the scan outputthrough
out_projwithout casting it to the projection weight dtype. Because the SSM kernels(
mamba_chunk_scan_combined/selective_state_update) return fp32 regardless of the moduledtype, the projection fails whenever
out_proj.weightis a narrower dtype than the activations:Fix
Cast the projection input to the
out_projweight dtype before both explicitout_projcalls inthe CUDA-kernel path, so the matmul dtypes always agree (matching the slow path's intent, and
robust to mixed-dtype models):
NemotronHMamba2Mixerinherits this method fromZamba2MambaMixer, so the fix is applied in themodular source
models/zamba2/modular_zamba2.pyand propagated to the generatedmodeling_zamba2.pyandmodeling_nemotron_h.py.